package simple.query;

import java.util.List;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

@IocBean
public class RoleQuery {
    @Inject
    private Dao dao;

    public List<String> queryUserMenu(String userId){
        String sqlStr = "select trm.menu_id from tbl_user_role tur left join tbl_role_menu trm on trm.role_id = tur.role_id where tur.user_id =@userId";
        Sql sql = Sqls.create(sqlStr);
        sql.setCallback(Sqls.callback.strList());
        sql.setParam("userId", userId);
        dao.execute(sql);
        return sql.getList(String.class);
    }
}
